﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.IO.MemoryMappedFiles;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;

using Autodesk.AutoCAD.Windows;


using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using DBTransMan = Autodesk.AutoCAD.DatabaseServices.TransactionManager;
//using doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiAcitveDocument;

[assembly: ExtensionApplication(typeof(pallete_main.PalleteMain))]


namespace pallete_main
{
    public class PalleteMain : IExtensionApplication
    {
        private Autodesk.AutoCAD.Windows.PaletteSet ps;
     //   private Autodesk.AutoCAD.Windows.PaletteSet ps2;

        [CommandMethod("CreatePallete")]
        public void CreatePallete()
        {

/*           System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"FServer.exe"); 
             psi.RedirectStandardOutput = true; 
             psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 
             psi.UseShellExecute = false; 
             System.Diagnostics.Process listFiles; 
             listFiles = System.Diagnostics.Process.Start(psi); */
/*
            try
            {
                using (var file = MemoryMappedFile.OpenExisting("myFile"))
                {
                    using (var reader = file.CreateViewAccessor(0, 100))
                    {
                        int len = reader.ReadInt32(0);

                        char[] bytes = new char[len];

                        reader.ReadArray<char>(4, bytes, 0, bytes.Length);

                    }
                }
            }
            catch (System.Exception ee)
            {

            }
*/
            ps = new Autodesk.AutoCAD.Windows.PaletteSet("main pallete");
            ps.MinimumSize = new System.Drawing.Size(10, 300);
            ps.Style = PaletteSetStyles.ShowCloseButton;
//            ps.DockEnabled = 0;// DockSides.Left | DockSides.Right;
            System.Windows.Forms.UserControl myCtrl1 = new MainForm();
            ps.Add("工程1", myCtrl1);
            ps.Visible = true;
       //     ps.Style = PaletteSetStyles.Snappable;
            ps.Dock = DockSides.Left;
            ps.KeepFocus = true;

        /*    pallete_scada scada = new pallete_scada();
            ps.Add("scada",scada);
            ps.Activate(0);
*/
            /*
            ps2 = new Autodesk.AutoCAD.Windows.PaletteSet("Test Palette Set 2");
            ps2.MinimumSize = new System.Drawing.Size(30, 300);
            //ps2.DockEnabled = 0;// DockSides.Right | DockSides.Left;
            ps2.Style = PaletteSetStyles.ShowCloseButton; 
            System.Windows.Forms.UserControl myCtrl2 = new MainFormDevice();
            ps2.Add("test2", myCtrl2);
            
            ps2.Visible = true;
            ps2.Dock = DockSides.Right;
             * */
        }

        public void Initialize()
        {
            CreatePallete();
         }
        public void Terminate()
        {
        }

    }

}

